package com.neegix.system.role.infrastructure.repository.impl;

import com.neegix.application.query.NebulaSQL;
import com.neegix.base.PageVO;
import com.neegix.system.role.application.assembler.RoleAssembler;
import com.neegix.system.role.application.repository.RoleQueryRepository;
import com.neegix.system.role.infrastructure.repository.dataobject.RoleDO;
import com.neegix.system.role.infrastructure.repository.mapper.RoleMapper;
import com.neegix.system.role.infrastructure.repository.mapper.customized.RoleCustomizedMapper;
import com.neegix.system.role.interfaces.vo.RolePageVO;
import com.neegix.system.role.interfaces.vo.RoleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

 /**
  * This file is auto-generated by nebula-framework-generator.
  * The auto-generation plugin was developed using IntelliJ IDEA Community Edition.
  * Thanks to JetBrains for their outstanding contributions to the developer community.
  * <p>
  * The code generated by this tool is owned by the user of the tool.
  * The tool itself is copyrighted by <a href="https://www.neegix.com">https://www.neegix.com</a>.
  *
  * @author <a href="https://www.neegix.com">https://www.neegix.com</a>
  * @version 1.0.0
  * @since 2024-11-25 11:32:40
  */

@Repository
public class RoleQueryRepositoryImpl implements RoleQueryRepository {

    @Autowired
    private RoleMapper roleMapper;

    @Autowired
    private RoleCustomizedMapper roleCustomizedMapper;


    @Override
    public PageVO<RolePageVO> findPage(Integer currentPage, Integer pageSize, NebulaSQL nebulaSQL) {
        List<RoleDO> result = roleMapper.selectList(nebulaSQL);
        Long total = roleMapper.selectCount(nebulaSQL);
        PageVO<RolePageVO> page = new PageVO<>(currentPage, pageSize);
        page.setTotal(total);
        page.setResult(RoleAssembler.INSTANCE.convertToVO(result));
        return page;
    }

     @Override
     public List<RoleVO> findAll() {
         NebulaSQL nebulaSQL = new NebulaSQL();
         return RoleAssembler.INSTANCE.covertVO(roleMapper.selectList(nebulaSQL));
     }
 }
